﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AddRole.ascx.cs" Inherits="Member_Control_AddRole" %>
<%@ Import Namespace="MP.Core.Config" %>

<script src="/Member/js/role.js" type="text/javascript"></script>

<div>
    <h2>
        Tạo quyền truy cập
    </h2>
    <div id="addrole" runat="server">
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" CssClass="valid-erorr"
            ValidationGroup="role" />
        <asp:CustomValidator ID="validRole" runat="server" ErrorMessage="CustomValidator"
            Display="None" ValidationGroup="role" OnServerValidate="validRole_ServerValidate"></asp:CustomValidator>
        <div>
            Tên quyền
            <asp:TextBox ID="txtRoleName" runat="server" ValidationGroup="role"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Nhập tên quyền"
                Text="*" ControlToValidate="txtRoleName" Display="Dynamic" ValidationGroup="role"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Tên quyền không được nhập ký tự đặc biệt"
                ValidationExpression="[a-zA-Z0-9\s\u00E0-\uFFFF]+" ControlToValidate="txtRoleName"
                Display="Dynamic" ValidationGroup="role">*</asp:RegularExpressionValidator>
            <span class="button fix">
                <asp:Button ID="btnAddRole" runat="server" Text="Thêm" ValidationGroup="role" OnClick="btnAddRole_Click" />
                <span>
                </span>
            </span>
        </div>
    </div>
</div>
<div style="margin: 15px 0">
    <table width="100%" class="grid">
        <tr>
            <th width="40">
            </th>
            <th>
                Tên quyền
            </th>
            <%--<th width="70px">
                Cấp độ
            </th>--%>
            <th width="40px">
            </th>
            <th width="40px">
            </th>
            <th width="40px">
            </th>
        </tr>
        <asp:Repeater ID="repRoles" runat="server" OnItemCommand="repRoles_ItemCommand">
            <ItemTemplate>
                <tr>
                    <td align="center">
                        <%# Container.ItemIndex + 1 %>
                    </td>
                    <td>
                        <div class='click r-<%# Eval("RoleId") %>' id='<%# Eval("RoleId") %>' role='<%# Eval("RoleName") %>'>
                            <span class='s-<%# Eval("RoleId") %>'>
                                <%# Eval("RoleName") %></span>
                        </div>
                        <div class='edit-<%# Eval("RoleId") %> r-<%# Eval("RoleId") %>' style="display: none">
                            <div class='process-<%# Eval("RoleId") %>'>
                                <input type="text" id='r-<%# Eval("RoleId") %>' value='<%# Eval("RoleName") %>' />
                                <span class="edit">
                                    <img src="/images/button/accept.png" />
                                </span><span class="close">
                                    <img src="/images/button/delete.png" />
                                </span>
                            </div>
                            <div class='process-<%# Eval("RoleId") %>' style="display: none">
                                <img src="/images/ajax-loader.gif" />
                            </div>
                        </div>
                    </td>
                    <%--<td align="center">
                        <asp:TextBox ID="txtLevel" runat="server" Width="30px" Text='<%# Eval("RoleLevel") %>'></asp:TextBox>
                        <asp:LinkButton ID="LinkButton2" runat="server" CommandArgument='<%# Eval("RoleName") %>'
                            CommandName="enable">
                            <img src='/images/button/accept.png'/>
                        </asp:LinkButton>
                    </td>--%>
                    <td align="center">
                        <% if (IsAction(EnumActions.ADD))
                           { %>
                        <div id="div1" runat="server" visible='<%# Convert.ToBoolean(Eval("IsEnable"))%>'>
                            <a href='/Member/RoleModules.aspx?r=<%# Server.UrlEncode(Eval("RoleName").ToString()) %>'
                                title="Chức năng">
                                <img src="/images/button/modules.png" title="Chức năng" alt="Chức năng" /></a>
                        </div>
                        <div id="div2" runat="server" visible='<%# !Convert.ToBoolean(Eval("IsEnable"))%>'>
                            <img src="/images/button/modules2.png" title="Chức năng" alt="Chức năng" />
                        </div>
                        <%}
                           else
                           { %>
                        <img src="/images/button/modules2.png" title="Chức năng" alt="Chức năng" />
                        <%} %>
                    </td>
                    <td align="center">
                        <% if (IsAction(EnumActions.ENABLE))
                           { %>
                        <asp:LinkButton ID="enable" runat="server" CommandArgument='<%# Eval("RoleName") %>'
                            CommandName="enable" ToolTip="Bật/tắt quyền" OnClientClick="return confirm('Xác nhận thay đổi tình trạng quyền?')">
                            <img src='/images/button/<%# viewImgEnable(Convert.ToBoolean(Eval("IsEnable"))) %>.png'/>
                        </asp:LinkButton>
                        <%}
                           else
                           { %>
                        <img src='/images/button/<%# viewImgEnable(Convert.ToBoolean(Eval("IsEnable"))) %>2.png'
                            title="Bật/tắt quyền" alt="Bật/tắt quyền" />
                        <%} %>
                    </td>
                    <td align="center">
                        <% if (IsAction(EnumActions.DELETE))
                           { %>
                        <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("RoleId").ToString() + "|" + Eval("RoleName").ToString() %>'
                            CommandName="del" OnClientClick="return confirm('Xác nhận xóa?')" ToolTip="Xóa quyền">
                            <img src="/images/button/delete.png"/>
                        </asp:LinkButton>
                        <%}
                           else
                           { %>
                        <img src="/images/button/delete2.png" title="Xóa quyền" alt="Xóa quyền" />
                        <%} %>
                    </td>
                </tr>
            </ItemTemplate>
        </asp:Repeater>
    </table>
</div>
